package com.bier.fishproject.activity;

import java.util.List;
import com.bier.fishproject.R;
import com.bier.fishproject.adapter.CardListAdapter;
import com.bier.fishproject.entity.Infos;
import com.bier.fishproject.utils.Base64Str;
import com.bier.fishproject.utils.NationUtils;
import com.mining.app.zxing.view.CustomListView;
import com.mining.app.zxing.view.RoundView;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.ScrollView;
import android.widget.TextView;
/**
 * 主卡，副卡的列表
 * @author Administrator
 *
 */
public class CardListActivity extends BaseActivity{

	private TextView tvName,tvSex,tvMin,tvYear,tvMonth,tvDay,tvAddress,tvScodes,tvPhone,tvBindCode,tvMoney,tvNum,tvFnum,tvF;
	private CustomListView listView;
	private RoundView rz,rf;
	private ScrollView sc;
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_cardlist);
		initView();
	}
	
	/**
	 * 初始化方法
	 */
	@SuppressLint("ResourceAsColor") private void initView(){
		tvName=(TextView)findViewById(R.id.tv_ei_names);
		tvSex=(TextView)findViewById(R.id.tv_ei_sexs);
		tvMin=(TextView)findViewById(R.id.tv_ei_mins);
		tvYear=(TextView)findViewById(R.id.tv_ei_years);
		tvMonth=(TextView)findViewById(R.id.tv_ei_months);
		tvDay=(TextView)findViewById(R.id.tv_ei_days);
		tvAddress=(TextView)findViewById(R.id.tv_ei_addresss);
		tvScodes=(TextView)findViewById(R.id.tv_ei_scodes);
		tvPhone=(TextView)findViewById(R.id.tv_ci_phone);
		tvBindCode=(TextView)findViewById(R.id.tv_ci_bindCode);
		tvMoney=(TextView)findViewById(R.id.tv_ci_money);
		tvNum=(TextView)findViewById(R.id.tv_ci_spendNum);
		listView=(CustomListView)findViewById(R.id.list_ac);
		tvFnum=(TextView)findViewById(R.id.tv_ac_fnum);
		tvF=(TextView)findViewById(R.id.tv_ci_fnum);
		rz=(RoundView)findViewById(R.id.round_ac_z);
		rf=(RoundView)findViewById(R.id.round_ac_f);
		sc=(ScrollView)findViewById(R.id.sc_ac);
		rz.setBackgroundColor(Color.BLUE);
		rf.setBackgroundColor(Color.GREEN);
		Bundle bundle=getIntent().getExtras();
		if(bundle!=null){
			List<Infos> listInfos=(List<Infos>) bundle.getSerializable("result");
			for (int i = 0,len=listInfos.size(); i < len; i++) {
				if(listInfos.get(i).getCtype().equals("1")){
					Infos infos=listInfos.get(i);
					tvF.setText("副卡个数");
					tvName.setText(Base64Str.getFromBase64(infos.getIname()));
					if(infos.getIsex().equals("1")){
						tvSex.setText("男");
					}else{
						tvSex.setText("女");
					}
					tvMin.setText(NationUtils.getMin(infos.getInation()));
					tvAddress.setText(Base64Str.getFromBase64(infos.getAddr()));
					tvScodes.setText(infos.getInum());
					tvPhone.setText(infos.getPn());
					tvMoney.setText(infos.getCdeal());
					tvNum.setText(infos.getCdealcount());
					if(!TextUtils.isEmpty(infos.getIbirth())){
						String[] str=infos.getIbirth().split("\\.");
						if(null!=str && str.length>0){
							tvYear.setText(str[0]);
							tvMonth.setText(str[1]);
							tvDay.setText(str[2]);
						}
					}
				}
			}
			tvBindCode.setText(String.valueOf((listInfos.size()-1)));
			tvFnum.setText("副卡"+(listInfos.size()-1)+"张");
			CardListAdapter adapter=new CardListAdapter(getApplicationContext(), listInfos);
			listView.setAdapter(adapter);
			listView.setDivider(null);
			sc.smoothScrollTo(0, 0);
		}
		//返回
		findViewById(R.id.img_ac_next).setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				CardListActivity.this.finish();
			}
		});
	}
}
